class Common {
    constructor(store, options) {
        this.store = store;
        this.options = options;
        this.install();
        return this;
    }
    install() {
        this.store.registerModule(["common"], this.options.data());
        let obj = this.options.mixin();
        for (let n in obj) {
            if (n !== "data") this[n] = obj[n];
        }
        return this;
    }
    uninstall() {
        this.store.unregisterModule(["common"]);
        return this;
    }
}

export const common = function(Vue, store) {
    return new Promise((resolve, reject) => {
        try {
            Vue.prototype.$common = Vue.$common = new Common(store, {
                data() {
                    return {
                        state: {},
                        actions: {},
                        mutations: {},
                    };
                },
                mixin() {
                    return {};
                },
            });
            resolve(Vue);
        } catch (e) {
            reject(e);
        }
    });
};